package com.ruoyi.pcr.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pcr.domain.Pcr;
import com.ruoyi.pcr.service.IPcrService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 核酸检测查询Controller
 *
 * @author 刘焕然
 * @date 2022-11-19
 */
@RestController
@RequestMapping("/pcr/pcr")
public class PcrController extends BaseController
{
    @Autowired
    private IPcrService pcrService;

    /**
     * 查询核酸检测查询列表
     */
    @PreAuthorize("@ss.hasPermi('pcr:pcr:list')")
    @GetMapping("/list")
    public TableDataInfo list(Pcr pcr)
    {
        startPage();
        List<Pcr> list = pcrService.selectPcrList(pcr);
        return getDataTable(list);
    }

    /**
     * 导出核酸检测查询列表
     */
    @PreAuthorize("@ss.hasPermi('pcr:pcr:export')")
    @Log(title = "核酸检测查询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Pcr pcr)
    {
        List<Pcr> list = pcrService.selectPcrList(pcr);
        ExcelUtil<Pcr> util = new ExcelUtil<Pcr>(Pcr.class);
        util.exportExcel(response, list, "核酸检测查询数据");
    }

    /**
     * 获取核酸检测查询详细信息
     */
    @PreAuthorize("@ss.hasPermi('pcr:pcr:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pcrService.selectPcrById(id));
    }

    /**
     * 新增核酸检测查询
     */
    @PreAuthorize("@ss.hasPermi('pcr:pcr:add')")
    @Log(title = "核酸检测查询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Pcr pcr)
    {
        return toAjax(pcrService.insertPcr(pcr));
    }

    /**
     * 修改核酸检测查询
     */
    @PreAuthorize("@ss.hasPermi('pcr:pcr:edit')")
    @Log(title = "核酸检测查询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Pcr pcr)
    {
        return toAjax(pcrService.updatePcr(pcr));
    }

    /**
     * 删除核酸检测查询
     */
    @PreAuthorize("@ss.hasPermi('pcr:pcr:remove')")
    @Log(title = "核酸检测查询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pcrService.deletePcrByIds(ids));
    }

   /* *//**
     *
     * @param idCards
     * @return
     *//*
    @PreAuthorize("@ss.hasPermi('pcr:pcr:remove')")
    @Log(title = "核酸检测查询", businessType = BusinessType.DELETE)
    @DeleteMapping("/{idCards}")
    public AjaxResult remove(@PathVariable String[] idCards)
    {
        return toAjax(pcrService.deletePcrByIdCards(idCards));
    }*/
}
